package behaviourNavigatore;

import navigatore.AgenteNavigatore;
import jade.core.behaviours.FSMBehaviour;

public class MyFSM extends FSMBehaviour{
	
	private RegistrationYellowPage regYellowPage = new RegistrationYellowPage();
	
	private GenerateRoute genRoute = new GenerateRoute();
	private PutInTheStreet putStreet = new PutInTheStreet();
	//private PutInTheStreet2 putStreet = new PutInTheStreet2();
	private UpdateAutoPosition updateAuto = new UpdateAutoPosition();
	private ManageCrossroads manageCrossRoad = new ManageCrossroads();
	private SuspendFSM finalState = new SuspendFSM();
	private BargainingStreets bargainingStreet = new BargainingStreets();
	
	private AgenteNavigatore navigatore;
	
	public MyFSM() {
		// TODO Auto-generated constructor stub
		
		navigatore = (AgenteNavigatore)myAgent;
		
		//definisco gli stati dell' automa!
		this.registerFirstState(regYellowPage, "RYP");
		this.registerState(genRoute, "GR");
		this.registerState(putStreet, "PS");
		this.registerState(updateAuto, "UA");
		this.registerState(manageCrossRoad, "MC");
		this.registerState(bargainingStreet, "BS");
		this.registerLastState(finalState, "FS");
		//definisco le transizioni di stato
		this.registerDefaultTransition("RYP", "GR");
		
		//putInTheStreet
		this.registerDefaultTransition("PS", "UA");
		//manageCrossRoads
		this.registerDefaultTransition("MC", "BS");
		//BargainingStreets
		this.registerTransition("BS", "UA", navigatore.BARGAININGSTREET_TO_UPDATE_AUTO_POSITION);
		this.registerTransition("BS", "GR", navigatore.BARGAININGSTREET_TO_GENERATEROUTE);
		this.registerTransition("BS", "PS", navigatore.BARGAININGSTREET_TO_PUTINSTREET);
		this.registerTransition("BS", "BS", navigatore.CONTINUE_TO_BARGAININGSTREET);
		//generateRoute
		this.registerTransition("GR", "GR", navigatore.CONTINUE_TO_GENRATE_RUOTE);
		this.registerTransition("GR", "PS", navigatore.GENROUTE_TO_PUTINSTREET);
		this.registerTransition("GR", "FS", navigatore.FINALSTATE);
		//updateAutoPositiongen
		this.registerTransition("UA", "UA", navigatore.CONTINUE_TO_UPDATE_AUTO_POSITION);
		this.registerTransition("UA", "MC", navigatore.UPDATEPOSITION_TO_MANAGECROSSROAD);
		this.registerTransition("UA", "GR", navigatore.UPDATEPOSITION_TO_GENERATEROUTE);
		this.registerTransition("UA", "PS", navigatore.UPDATEPOSITION_TO_PUTINSTREET);
		this.registerTransition("UA", "BS", navigatore.UPDATEPOSITION_TO_BAGARGINGSTREET);
		
		
	}
	
}
